#include <cstdio>
#include <cstring>

char str[ 2001 ];

void work( )
{
    int i, left = 0, right = 0, ans = 0;
    for ( i = 0; i < strlen( str ); i++ )
    {
        if ( str[ i ] == '{' )
            left++;
        if ( str[ i ] == '}' )
        {
            if ( left == 0 )
            {
                left++;
                ans++;
            }
            else
            {
                left--;
                right--;
            }
        }
    }
    printf("%d\n", ans + left / 2);
}

int main( )
{
    int cas = 1;
    while ( gets( str ) && str[ 0 ] != '-' )
    {
        printf("%d. ", cas++);
        work( );
    }
    return 0;
}
